//
//  KKNetworkingManager.m
//  iFlyQDMG
//
//  Created by ifly on 2017/8/8.
//  Copyright © 2017年 Meiyang. All rights reserved.
//

#import "KKNetworkingManager.h"


#pragma marlk  ============  网络请求请求管理着 =============

@interface KKNetworkingManager ()

@end

@implementation KKNetworkingManager

#pragma mark - GET 请求的三种回调方法
+ (KKURLSessionTask *)getRequstWithURL:(NSString*)url
                                 params:(NSDictionary*)params
                                 target:(id)target
                                 action:(SEL)action
                               delegate:(id)delegate
                           successBlock:(KKResponseSuccess)successBlock
                           failureBlock:(KKResponseFail)failureBlock
                               progress:(KKGetProgress)progress
                           refreshCache:(BOOL)refreshCache
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionaryWithDictionary:params];
    return [KKNetworkingObject initWithtype:KKNetWorkTypeGET url:url params:mutableDict refreshCache:refreshCache delegate:delegate target:target action:action hashValue:0  progress:progress successBlock:successBlock failureBlock:failureBlock];
}


+ (KKURLSessionTask *)getRequstWithURL:(NSString *)url
                                 params:(NSDictionary *)paramsDict
                           successBlock:(KKResponseSuccess)successBlock
                           failureBlock:(KKResponseFail)failureBlock
                               progress:(KKGetProgress)progress
                           refreshCache:(BOOL)refreshCache
{
    return [self getRequstWithURL:url params:paramsDict target:nil action:nil delegate:nil successBlock:successBlock failureBlock:failureBlock progress:progress refreshCache:refreshCache];
}


+ (KKURLSessionTask *)getRequstWithURL:(NSString*)url
                                 params:(NSDictionary*)paramsDict
                              delegate:(id<KKNetworkDelegate>)delegate
                               progress:(KKGetProgress)progress
                           refreshCache:(BOOL)refreshCache
{
    return [self getRequstWithURL:url params:paramsDict target:nil action:nil delegate:delegate successBlock:nil failureBlock:nil progress:progress refreshCache:refreshCache ];
}

+ (KKURLSessionTask *)getRequstWithURL:(NSString*)url
                                 params:(NSDictionary*)paramsDict
                                 target:(id)target
                                 action:(SEL)action
                               progress:(KKGetProgress)progress
                           refreshCache:(BOOL)refreshCache{
    return [self getRequstWithURL:url params:paramsDict target:target action:action delegate:nil successBlock:nil failureBlock:nil progress:progress refreshCache:refreshCache ];
}

#pragma mark - 发送 POST 请求的方法

+ (KKURLSessionTask *)postReqeustWithURL:(NSString*)url
                                   params:(NSDictionary*)params
                                   target:(id)target
                                   action:(SEL)action
                                delegate:(id<KKNetworkDelegate>)delegate
                             successBlock:(KKResponseSuccess)successBlock
                             failureBlock:(KKResponseFail)failureBlock
                                 progress:(KKGetProgress)progress
                             refreshCache:(BOOL)refreshCache
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionaryWithDictionary:params];
    return [KKNetworkingObject initWithtype:KKNetWorkTypePOST url:url params:mutableDict refreshCache:refreshCache delegate:delegate target:target action:action hashValue:1  progress:progress successBlock:successBlock failureBlock:failureBlock];
}


+ (KKURLSessionTask *)postReqeustWithURL:(NSString*)url
                                   params:(NSDictionary*)paramsDict
                             successBlock:(KKResponseSuccess)successBlock
                             failureBlock:(KKResponseFail)failureBlock
                                 progress:(KKGetProgress)progress
                             refreshCache:(BOOL)refreshCache
{
    return [self postReqeustWithURL:url params:paramsDict target:nil action:nil delegate:nil successBlock:successBlock failureBlock:failureBlock progress:progress refreshCache:refreshCache ];
}

+ (KKURLSessionTask *)postReqeustWithURL:(NSString*)url
                                   params:(NSDictionary*)paramsDict
                                delegate:(id<KKNetworkDelegate>)delegate
                                 progress:(KKGetProgress)progress
                             refreshCache:(BOOL)refreshCache

{
    return [self postReqeustWithURL:url params:paramsDict target:nil action:nil delegate:delegate successBlock:nil failureBlock:nil progress:progress refreshCache:refreshCache ];
}

+ (KKURLSessionTask *)postReqeustWithURL:(NSString*)url
                                   params:(NSDictionary*)paramsDict
                                   target:(id)target
                                   action:(SEL)action
                                 progress:(KKGetProgress)progress
                             refreshCache:(BOOL)refreshCache

{
    return [self postReqeustWithURL:url params:paramsDict target:target action:action delegate:nil successBlock:nil failureBlock:nil progress:progress refreshCache:refreshCache ];
}

@end

